ia64: Fixes after changes to grant table code.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 19 Feb 2007 16:06:03 +0000 (16:06 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 19 Feb 2007 16:06:03 +0000 (16:06 +0000)
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
xen/arch/ia64/xen/domain.c
xen/include/asm-ia64/grant_table.h

index 9c21d0294955a38a10be87f8e6166d989507b59d..6eb764d30cbd98d0bfc6a9256e9f0abd5116e28c 100644 (file)
@@ -521,6 +521,16 @@ int arch_domain_create(struct domain *d)
        if ((d->arch.mm.pgd = pgd_alloc(&d->arch.mm)) == NULL)
            goto fail_nomem;
 
+       /*
+        * grant_table_create() can't fully initialize grant table for domain
+        * because it is called before arch_domain_create().
+        * Here we complete the initialization which requires p2m table.
+        */
+       spin_lock(&d->grant_table->lock);
+       for (i = 0; i < nr_grant_frames(d->grant_table); i++)
+               ia64_gnttab_create_shared_page(d, d->grant_table, i);
+       spin_unlock(&d->grant_table->lock);
+
        d->arch.ioport_caps = rangeset_new(d, "I/O Ports",
                                           RANGESETF_prettyprint_hex);
 
index 106b0aad68638aae039284990e4b9f67c94de128..45d7dac7e942eb47be436b77aac3a49a51b17ddb 100644 (file)
@@ -14,15 +14,6 @@ int destroy_grant_host_mapping(unsigned long gpaddr, unsigned long mfn, unsigned
 // for grant transfer
 void guest_physmap_add_page(struct domain *d, unsigned long gpfn, unsigned long mfn);
 
-// for grant table shared page
-#define gnttab_create_shared_page(d, t, i)                              \
-    do {                                                                \
-        share_xen_page_with_guest(                                      \
-            virt_to_page((char *)(t)->shared + ((i) << PAGE_SHIFT)),    \
-            (d), XENSHARE_writable);                                    \
-    } while (0)
-
-
 /* XXX
  * somewhere appropriate
  * those constand shouldn't be pre-defined and
@@ -39,14 +30,32 @@ void guest_physmap_add_page(struct domain *d, unsigned long gpfn, unsigned long
 /* Guest physical address of the grant table.  */
 #define IA64_GRANT_TABLE_PADDR  IA64_XMAPPEDREGS_PADDR(NR_CPUS)
 
-#define gnttab_shared_maddr(d, t, i)                        \
-    virt_to_maddr((char*)(t)->shared + ((i) << PAGE_SHIFT))
+#define gnttab_shared_maddr(t, i)       (virt_to_maddr((t)->shared[(i)]))
+#define gnttab_shared_page(t, i)        (virt_to_page((t)->shared[(i)]))
+
+#define ia64_gnttab_create_shared_page(d, t, i)                         \
+    do {                                                                \
+        BUG_ON((d)->arch.mm.pgd == NULL);                               \
+        assign_domain_page((d),                                         \
+                           IA64_GRANT_TABLE_PADDR + ((i) << PAGE_SHIFT), \
+                           gnttab_shared_maddr((t), (i)));              \
+    } while (0)
+
+/*
+ * for grant table shared page
+ * grant_table_create() might call this macro before allocating the p2m table.
+ * In such case, arch_domain_create() completes the initialization.
+ */
+#define gnttab_create_shared_page(d, t, i)                      \
+    do {                                                        \
+        share_xen_page_with_guest(gnttab_shared_page((t), (i)), \
+                                  (d), XENSHARE_writable);      \
+        if ((d)->arch.mm.pgd)                                   \
+            ia64_gnttab_create_shared_page((d), (t), (i));      \
+    } while (0)
 
-# define gnttab_shared_gmfn(d, t, i)                                    \
-    ({ assign_domain_page((d),                                          \
-                          IA64_GRANT_TABLE_PADDR + ((i) << PAGE_SHIFT), \
-                          gnttab_shared_maddr((d), (t), (i)));          \
-        (IA64_GRANT_TABLE_PADDR >> PAGE_SHIFT) + (i);})
+#define gnttab_shared_gmfn(d, t, i)                 \
+    ((IA64_GRANT_TABLE_PADDR >> PAGE_SHIFT) + (i))
 
 #define gnttab_mark_dirty(d, f) ((void)f)